package com.wjm.demo.test1.net_test.tcp_socket_test.uploadpic;


import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class UploadPicClient {
    public static void main(String[] args) throws Exception {
        Socket s = new Socket("192.168.0.101", 10001);
        FileInputStream fis = new FileInputStream("d:\\微信截图_20180707211416.png");
        OutputStream out = s.getOutputStream();
        int len;
        byte[] buf = new byte[1024];
        while ((len = fis.read(buf)) != -1) {
            out.write(buf, 0, len);
        }
        s.shutdownOutput();//结束标记

        InputStream is = s.getInputStream();
        byte[] bytes = new byte[1024];
        int bytesLen = is.read(bytes);
        String str = new String(bytes, 0, bytesLen);
        System.out.println(str);
        fis.close();
        s.close();
    }
}
